package com.Web;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import util.DateUtil;
import com.Dao.GoalDao;
import com.entity.Employee;
import com.entity.Goal;
import com.entity.employProject;


public class addSavaGoal extends HttpServlet {


	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session = request.getSession();
	 	employProject ep = (employProject) session.getAttribute("ep");
		Employee em =  (Employee) session.getAttribute("em");
		
		String name = request.getParameter("name");
		String desc = request.getParameter("area");
		
		GoalDao gdao = new GoalDao();
		Goal g = new Goal();
		
		g.setName(name);
		g.setDesc(desc);
		g.setCreatetime(DateUtil.getNow());
		g.setEmployeeid(em.getId());
		g.setProjectid(ep.getProjectid());
		
		gdao.sava(g);
		
		session.setAttribute("g", g.getId());
	request.getRequestDispatcher("/WEB-INF/views/goal.jsp").forward(request, response);
	}
	
}
